﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10.ResourceFile;
using The_Chronicles_of_Asku.Characters;
namespace The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10
{
    class FloorEight
    {
        Battle battle = new Battle();
        Skeleton skel = new Skeleton();
        Necromancer necro = new Necromancer();
        Undead zombie = new Undead();
        SetMobLevels setLevel = new SetMobLevels();
        Hero myHero = new Hero();
        Villager villager = new Villager();
        public bool complete = false;

        public void theFloor(Hero myHero, Mob mob)
        {
            setLevel.setMobLevelFourteen(skel, necro, zombie, villager);

            Console.WriteLine(FloorEightText.Entrance);
            VillagerFight(myHero, villager);
            VillagerFight(myHero, villager);
            VillagerFight(myHero, villager);
            VillagerFight(myHero, villager);
            VillagerFight(myHero, villager);

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorEightText.First);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
            }

            if (myHero.isAlive == true)
            {
                string firstAnswer = "";
                do
                {
                    Console.WriteLine(FloorEightText.SecondThing);
                    firstAnswer = Console.ReadLine();

                    switch (firstAnswer)
                    {
                        case "1":
                            Console.WriteLine(FloorEightText.LeftFirst);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            break;
                            
                        case "2":
                            Console.WriteLine(FloorEightText.RightFirst);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            break;

                        default:
                            Console.WriteLine("Invalid Choice!");
                            ClearScreen();
                            break;
                    }

                } while (firstAnswer != "1" && firstAnswer != "2" && myHero.isAlive == true);
            }

            if (myHero.isAlive == true)
            {
                string secondAnswer = "";

                do
                {
                    Console.WriteLine(FloorEightText.DoorAndCrawlSpaceThird);
                    secondAnswer = Console.ReadLine();

                    switch (secondAnswer)
                    {
                        case "1":
                            Console.WriteLine(FloorEightText.DoorToThirdThing);
                            NecromancerFight(myHero, necro);
                            UndeadFight(myHero, zombie);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            UndeadFight(myHero, zombie);
                            NecromancerFight(myHero, necro);
                            break;

                        case "2":
                            Console.WriteLine(FloorEightText.FourthThing);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            Console.WriteLine(FloorEightText.CrawlSpaceToThirdThing);
                            ClearScreen();
                            Console.WriteLine(FloorEightText.DoorToThirdThing);
                            NecromancerFight(myHero, necro);
                            UndeadFight(myHero, zombie);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            UndeadFight(myHero, zombie);
                            NecromancerFight(myHero, necro);
                            break;

                        default:
                            Console.WriteLine("Invalid Choice!");
                            ClearScreen();
                            break;
                    }

                } while (secondAnswer != "1" && secondAnswer != "2" && myHero.isAlive == true);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorEightText.FifthThing);
                NecromancerFight(myHero, necro);
                VillagerFight(myHero, villager);
                VillagerFight(myHero, villager);
                VillagerFight(myHero, villager);
                VillagerFight(myHero, villager);
                VillagerFight(myHero, villager);
                VillagerFight(myHero, villager);
                VillagerFight(myHero, villager);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorEightText.SixthThing);
                SkeletonFight(myHero, skel);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
            }

            if (myHero.isAlive == true)
            {
                string thirdAnswer = "";

                do
                {
                    Console.WriteLine(FloorEightText.SventhThing);
                    thirdAnswer = Console.ReadLine();

                    switch (thirdAnswer)
                    {
                        case "1":
                            Console.WriteLine(FloorEightText.SixDoorOne);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            break;

                        case "2":
                            Console.WriteLine(FloorEightText.SixDoorTwo);
                            ClearScreen();
                            break;

                        case "3":
                            Console.WriteLine(FloorEightText.SixDoorThree);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            break;

                        default:
                            Console.WriteLine("Invalid Choice!");
                            ClearScreen();
                            break;
                    }

                } while (thirdAnswer != "1" && thirdAnswer != "3" && myHero.isAlive == true);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorEightText.End);
                ClearScreen();
                complete = true;
            }


            if (myHero.isAlive == false)
            {
                Console.WriteLine(FloorEightText.Dead);
                myHero.isAlive = true;
            }
        }

        private void UndeadFight(Hero myHero, Undead zombie)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, zombie);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            zombie.ResetStats(zombie);

            Console.Clear();
        }

        private void SkeletonFight(Hero myHero, Skeleton skel)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, skel);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            skel.ResetStats(skel);

            Console.Clear();
        }

        private void NecromancerFight(Hero myHero, Necromancer necro)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, necro);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            necro.ResetStats(necro);

            Console.Clear();
        }

        private void VillagerFight(Hero myHero, Villager villager)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, villager);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            villager.ResetStats(villager);

            Console.Clear();
        }

        private void ClearScreen()
        {
            Console.ReadKey();
            Console.Clear();
        }
    }
}
